package com.cq.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private String code;

    private String msg;

    private T data;

    public static <T> com.cq.result.Result<T> success() {
        return new com.cq.result.Result<>(com.cq.result.ContentResult.SUCCESS_CODE, com.cq.result.ContentResult.SUCCESS_MESSAGE,null);
    }

    public static <T> com.cq.result.Result<T> success(T data) {
        return new com.cq.result.Result<>(com.cq.result.ContentResult.SUCCESS_CODE, com.cq.result.ContentResult.SUCCESS_MESSAGE,data);
    }

    public static <T> com.cq.result.Result<T> success(String msg, T data) {
        return new com.cq.result.Result<>(com.cq.result.ContentResult.SUCCESS_CODE,msg,data);
    }

    public static <T> com.cq.result.Result<T> error(String msg) {
        return new com.cq.result.Result<>(ContentResult.ERROR_CODE,msg,null);
    }
}
